<template>
  <div>
    <h1>添加用户信息页面</h1>
    用户名：<input type="text" v-model="username" /><br />
    <input type="button" value="跳转至用户列表界面" @click="goToUserShow" />
  </div>
</template>

<script>
export default {
  data() {
    return {
      username: "",
    };
  },
  methods: {
    goToUserShow() {
      if (this.username.trim()) {
        this.$router.push({
          path: "/show",
          query: { username: this.username },
        });
      } else {
        alert("用户名不能为空！");
      }
    },
  },
};
</script>

<style scoped>
</style>